<template>
  <van-cell-group>
    <van-cell v-for="item in routerList" :key="item.name" :title="item.meta.title" is-link @click="toPage(item)">
    </van-cell>
  </van-cell-group>
</template>

<script>
import router from '.././router';
export default {
  name: '',
  data() {
    return {
      routerList: [],
    };
  },
  created() {
    console.log(router);
    this.filterMenu(router.options.routes);
  },
  methods: {
    filterMenu(menu) {
      if (menu && menu.length) {
        let formatedMenu = menu.forEach(item => {
          if (item.children && item.children.length) {
            this.filterMenu(item.children);
          }
          if (item.meta && item.meta.title) {
            this.routerList.push(item);
          }
        });
      }
    },
    toPage(item) {
      this.$router.push({
        name: item.name,
      });
    },
  },
};
</script>

<style lang="" scoped></style>
